<!-- 调剂信息 -->
<template>
	<view class="adjustInfo">
		<!-- 海报 -->
		<view style="padding: 30rpx;">
			<image v-for="(item,index) in banner" :key="item.id" lazy-load
				:src="item.url"
				mode="aspectFill" class="adju-img"></image>
				<view style="height: 140rpx;"></view>
		</view>
		<!-- 底部按钮 -->
		<view class="poBottom shadow-g-s"
			:style="{'padding-bottom' : osName == 'ios' ? 'calc(env(safe-area-inset-bottom) / 2 + 20rpx)' : '20rpx'}">
			<view class="flex font12 alignCenter justify-between">
				<view class="flex alignCenter">
					<view v-if="src1" class="call" style="margin-right: 50rpx;" @click="cumPopup = true">
						<image src="../static/question.svg" mode="widthFix"></image>
						<view style="font-size: 24rpx;">咨询</view>
					</view>
					<view class="initButton">
						<button @click="share" style="padding: 0;margin: 0;" open-type='share'>
							<image src="../static/share.svg" mode="widthFix"></image>
							<view style="font-size: 24rpx;">分享</view>
						</button>
					</view>
				</view>
				<view class="btn2 u-font-32 u-m-r-50" @click="handlePay">立即购买<view class="price u-font-24 u-m-t-5">
						(￥{{info.price}})</view>
				</view>
			</view>
		</view>
		<u-popup mode="center" v-model="cumPopup" :mask-close-able="false">
			<view class="flex flex-column align-center">
				<view class="bg-white flex flex-column align-center u-p-t-30 u-p-b-30"
					style="width: 528rpx;border-radius: 46rpx;">
					<image :src="src1" style="width: 220rpx;height: 220rpx;margin-top: 70rpx;" mode="" show-menu-by-longpress>
					</image>
					<view class="copy">复制微信号</view>
					<view class="call1 u-m-b-40">直接打电话</view>
				</view>
				<u-icon @click="cumPopup = false"
					name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/11/16/32e960d256be461795b684d9d7872559.png"
					size="100" class="u-m-t-50"></u-icon>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		queryGoodAllById,
		kefu,
		jihuomama,
		queryAllUrl
	} from "@/api/toolbox.js"

	export default {
		data() {
			return {
				cumPopup: false,
				info: {},
				height: 0,
				width: 0,
				src1: '',
				osName: '',
				banner: []
			}
		},
		onLoad() {
			this.getBanner();
		},
		onShow() {
			uni.setStorageSync('isNews', true);
			this.getData();
			let a = uni.getWindowInfo()
			this.height = a.screenHeight
			this.width = a.screenWidth
			var that = this
			uni.getSystemInfo({
				success: function(res) {
					console.log(res.osName);
					that.osName = res.osName
				}
			})

		},
		// #ifndef MP
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			return {
				title: '调剂咨询分享', //分享的名称
				path: '/pages/toolbox/adjustReport/adjustInfo',
				mpId: 'wx458429e4a9197b53' //此处配置微信小程序的AppId
			}
		},
		//分享到朋友圈
		onShareTimeline(res) {
			return {
				title: '调剂咨询分享',
				type: 0,
				summary: "",
			}
		},
		// #endif
		methods: {
			getBanner() {
				queryAllUrl().then(res => {
					if (res.code == 100000) {
						if (res.data && res.data.length) {
							this.banner = res.data.map(e => {
								return {
									url: e.url,
									id: e.id
								}
							});
						}
					}
					console.log('res: ', res);
				})
			},
			getData() {
				queryGoodAllById({
					id: '29'
				}).then(res => {
					if (res.code == 100000) {
						this.info = res.data;
					}
				})
				jihuomama().then((res) => {
					this.src1 = res.data
				})
			},
			handlePay() {
				let query = {
					type: 9, //8、单独购，9、全部购
					money: this.info.price,
					id: this.info.id
				}
				// 新增成功找人数据成功后,判断是否委托找人.是则关联委托人id,否则继续往下执行
				uni.redirectTo({
					url: '/pages/order/order?query=' + JSON.stringify(query)
				})
			},
			share() {
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					summary: "最新调剂信息~快来看看吧",
					miniProgram: {
						id: 'gh_f6d6838a4490',
						path: '/pages/toolbox/adjustReport/adjustInfo',
						type: 2,
					},
					success: function(res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},
		},
	}
</script>

<style lang="scss" scoped>
	.adjustInfo {
		display: flex;
		flex-direction: column;
		justify-content: space-around;

		.poBottom {
			position: fixed;
			bottom: 0px;
			background: #fff;
			padding: 20rpx 30rpx;
			left: 0;
			right: 0;

			image {
				width: 48rpx;
				height: 48rpx;
			}

			.initButton {
				button {
					margin: 0;
					padding: 0;
					border-radius: 0;
					border: none;
					background-color: transparent;
					line-height: 1.35;
				}

				button::after {
					border: none;
				}
			}

			.call {
				margin: 0 14rpx 0 28rpx;
			}

			.btn1 {
				background: #637086;
				margin: 0 30rpx 0 84rpx;
			}

			.btn2 {
				background: #F7DD5E;
				height: 100rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
			}

			.btn1,
			.btn2 {

				width: 240rpx;
				border-radius: 100rpx;
				text-align: center;
				line-height: 1rem;
				// justify-content: center;
				padding-top: 10rpx;
			}

			.price {
				color: #FF7101
			}

		}

		.adju-img {
			background: #cccccc;
			width: 100%;
			height: 80vh;
		}
	}

	.copy {
		background-color: #73839A;
		height: 92rpx;
		width: 340rpx;
		text-align: center;
		line-height: 92rpx;
		color: #333333;
		font-size: 28rpx;
		margin-top: 68rpx;
		border-radius: 100rpx;
	}

	.call1 {
		background-color: #F7DD5E;
		height: 92rpx;
		width: 340rpx;
		text-align: center;
		line-height: 92rpx;
		font-size: 28rpx;
		color: #333333;
		margin-top: 20rpx;
		border-radius: 100rpx;
	}
</style>